<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>收藏的商家</title>
    <link rel="stylesheet" href="../css/common.css">
    <link rel="stylesheet" href="../css/style_zj.css">
    <link rel="stylesheet" href="../layui/css/layui.css">
    <link rel="stylesheet" href="../fonts/iconfont.css">
</head>
<body>
<!--<div id="header_01_html">
    <iframe id="header_01" src="head_01.html" frameborder="0"></iframe>
</div>-->
<div class="content-box">
    <!--<div id="left_tab_html">
        <iframe id="left_tab" src="left_tab.html?x=5&y=3" frameborder="0"></iframe>
    </div>-->
    <div class="right-box layui-form" id="vue-box" v-cloak>
        <div class="content-admin">

            <div class="title-toggle">
                <div class="item active">广告轮播</div>
                <a href="banner_add_marketing.html"><span class="btn-sty11 ml-20">添加广告位</span></a>
            </div>
            <div class="banner-box" style="padding-top: 20px;padding-bottom: 50px;">
                <div class="banner-time-type">
                    <span><span>提示：</span>上传的广告图片有效期为<span class="color-home">24小时</span>，到期后自动下架。</span>
                    <span>剩余上传次数：<span class="color-home">{{30-totalNum}}次</span></span>
                </div>

                <div class="mb-40" v-for="(item,index) in list">
                    <div class="clearfix mb-40">
                        <div class="fl k sort">第<span class="c_blue">{{index+1}}</span>张</div>
                        <div class="img-c fl">
                            <img :src="imgBaseUrl + item.picUrl" alt="" >
                        </div>
                        <div class="fl">
                            <span class="btn-sty11" class="fl" :id="item.id" @click="delBanner(item.id)">移除</span>
                        </div>
                    </div>
                    <div class="clearfix">
                        <span class="fl k add-sty1">轮播地址：</span>
                        <div class="fl wid-b60" style="width: 18%"><input type="text" disabled v-model="item.link" class="layui-input"></div>
                        <span class="fl k add-sty1">开始时间：</span>
                        <input type="text" readonly="readonly" id="" v-model="item.startTime" class="layui-input js-dataVal" style="display: inline-block;width: 18%">
                    </div>
                </div>
            </div>
            <div class="text-c"></div>

        </div>
    </div>
</div>
<!--
<div>
    <iframe src="footer-record.html" style="width: 100%;border: none;height:60px;"></iframe>
</div>-->
<script src="../js/config.js"></script>

<script>
    var postData = {
        type:2,
    };
    var app = new Vue({
        el: '#vue-box',
        data:{
            imgBaseUrl: imgBaseUrl,
            list:[],
//            addbanner:'store_banner-add.html?id=',
//            type:localStorage.getItem('type'),
            storeId:localStorage.getItem('storeId'),
            totalNum:'',
        },
        mounted:function(){
            this.getBanner();
        },
        methods:{
            getBanner:function () {
                get_ajaxPage("/sys/banner/getMyBannerPage",{},function (data) {
                    app.list = data.data;
                    app.totalNum = data.count;
                })
            },
            delBanner:function (e) {
                $.ajax({
                    url:baseUrl+'/sys/banner/del',
                    type:'post',
                    data:{
                        id:e,
                        Token:localStorage.getItem("Token")
                    },
                    success:function (data) {
                        if(data.code==0){
                            layer.msg('删除成功')
                            app.getBanner();
                        }else{
                            layer.msg(data.msg);
                        }

                    }
                })

            },
            editBanner:function(id){
                window.location.href='banner_add_edit.html?id='+id;
            }
        }
    })

    //图片上传
    layui.use(['upload'], function () {
        var $ = layui.jquery, upload = layui.upload;
        //普通图片上传
        var uploadInst = upload.render({
            elem: '.upload_btn'
            ,multiple:true
            , url: baseUrl + '/file/upload?token=' + Token
            , before: function (obj) {
                loading = layer.load(1, {
                    shade: [0.1, '#fff'] //0.1透明度的白色背景
                });
            }
            , done: function (res, index) {
                //如果上传失败
                if (res.code > 0) {
                    return layer.msg.msg('上传失败');
                } else {
                    var data = res.data;
                    postData.picUrl = data.address;
                    $('.upload_btn').attr('src',imgBaseUrl+postData.picUrl);
                    layer.close(loading);
                    console.log('上传成功！')
                }

            }
            , error: function () {

            }
        });
    })






</script>
</body>
</html>